package com.xh.cdp.common.log;

import java.util.Date;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import com.xh.cdp.common.util.DateUtil;
import com.xh.cdp.sys.controller.UserController;

@Component
@Aspect
public class Log {
	
	private static Logger log = LogManager.getLogger(UserController.class);
	
	@Around("execution(* com.xh.cdp.*.controller.*.*(..))")
	public Object around(ProceedingJoinPoint pjp) throws Throwable {
		log.log(Level.INFO, "于 " + DateUtil.format(new Date()) + " " + pjp.getSignature() + "被执行");
		Object object = pjp.proceed();
		log.log(Level.INFO, "于 " + DateUtil.format(new Date()) + " " + pjp.getSignature() + "执行完毕");
		return object;
	}
}
